package com.cyf.db.mapper;

import com.cyf.db.bean.InviteRecord;
import org.apache.ibatis.annotations.*;

import java.util.Date;
import java.util.List;

/**
 * 受访者主动邀请记录
 * Created by cage on 2017/9/18.
 */

public interface InviteRecordMapper {

    @Insert("insert into invite_record(intervieweeId, mobile, createdTime, endTime) " +
            "values(#{intervieweeId}, #{mobile}, #{createdTime}, #{endTime}) ")
    void insertInviteRecord(InviteRecord inviteRecord);

    @Select("select * from invite_record where intervieweeId = #{intervieweeId} and mobile = #{mobile}")
    InviteRecord getByIntervieweeIdAndMobile(@Param("intervieweeId") Integer intervieweeId, @Param("mobile") String mobile);

    @Delete("delete from invite_record where id = #{id}")
    void deleteById(@Param("id") int id);

    @Delete("delete from invite_record where endTime <= #{now}")
    void timeout(@Param("now") Date now);

    @Select("select * from invite_record where mobile = #{mobile}")
    List<InviteRecord> getByMobile(@Param("mobile") String mobile);
}
